{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dd8c08eb-14c5-4f08-9634-e3a02bcebbc0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import cv2\n",
    "from MyTools import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "28d3b44c-c8d6-40d8-bcb4-69bc2b18f616",
   "metadata": {},
   "outputs": [],
   "source": [
    "yolo_labels_path = '../yolo_test_label'\n",
    "img_path = '/root/autodl-tmp/testing/image_2' #这里是testing的图片。这里还是需要读取对应图片，因为要逆归一化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3df7faaa-0c9c-4dc1-b36b-15c3a6dfe007",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0/11 has been done\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[ WARN:0@0.217] global loadsave.cpp:268 findDecoder imread_('/root/autodl-tmp/testing/image_2/000000.png'): can't open/read file: check file path/integrity\n"
     ]
    },
    {
     "ename": "AttributeError",
     "evalue": "'NoneType' object has no attribute 'shape'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43myolo_2_kitti\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43myolo_2_kitti\u001b[49m\u001b[43m(\u001b[49m\u001b[43mimg_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43myolo_labels_path\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/autodl-tmp/yolo_incremental_learning/yolo_2_kitti.py:29\u001b[0m, in \u001b[0;36myolo_2_kitti\u001b[0;34m(img_path, yolo_labels_path, save_path)\u001b[0m\n\u001b[1;32m     27\u001b[0m img_file \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(img_path, os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39msplitext(label)[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.png\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m     28\u001b[0m image \u001b[38;5;241m=\u001b[39m cv2\u001b[38;5;241m.\u001b[39mimread(img_file)\n\u001b[0;32m---> 29\u001b[0m o_h, o_w, o_c \u001b[38;5;241m=\u001b[39m \u001b[43mimage\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshape\u001b[49m\n\u001b[1;32m     30\u001b[0m \u001b[38;5;66;03m#为了逆归一化\u001b[39;00m\n\u001b[1;32m     32\u001b[0m lines \u001b[38;5;241m=\u001b[39m []\n",
      "\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'shape'"
     ]
    }
   ],
   "source": [
    "yolo_2_kitti.yolo_2_kitti(img_path, yolo_labels_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb974783-7ea0-4f1f-b9ec-18a61fe2fc72",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1fc435f2-399a-4ed9-8681-041b79cede41",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0/10 has been done\n"
     ]
    }
   ],
   "source": [
    "#yolo_2_kitti.yolo_2_kitti(img_path = '/root/autodl-tmp/devkit/val_img', yolo_labels_path = '/root/autodl-tmp/devkit/val_results/exp/labels', save_path = '/root/autodl-tmp/devkit/results')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "92872fc3-d793-42ab-820c-c0703f045eeb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
